package com.njtcedu.microblog.common.entity;

import java.io.Serializable;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

@Entity
@Table(name = "conten_referred", schema = "microblog")
public class ContentReferred implements Serializable{//提到我的微博
	
	@Id
	@GeneratedValue
	@Column(name = "id")
	private Integer id;
	
	@ManyToOne(cascade = CascadeType.REFRESH, optional = false)
	@JoinColumn(name = "referred_user", nullable = false)
	private User referredUser;//提到的用户
	
	@ManyToOne(cascade = CascadeType.REFRESH, optional = false)
	@JoinColumn(name = "content_id", nullable =false)
	private Content content;

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public User getReferredUser() {
		return referredUser;
	}

	public void setReferredUser(User referredUser) {
		this.referredUser = referredUser;
	}

	public Content getContent() {
		return content;
	}

	public void setContent(Content content) {
		this.content = content;
	}

	@Override
	public int hashCode() {
		return id != null ? id.hashCode() : 0;
	}

	@Override
	public boolean equals(Object obj) {
		if(this == obj) return true;
		if(obj == null || obj.getClass() == getClass()) return false;
		ContentReferred contentReferred = (ContentReferred)obj;
		return id != null ? id.equals(contentReferred.id) : contentReferred.id == null;
	}

	@Override
	public String toString() {
		return "ContentReferred [id=" + id + ", referredUser=" + referredUser
				+ ", content=" + content + "]";
	}
	
}
